<?php
include_once "quickcrud_connect.php";
include "CF_mysql_com.php";
//include_once "CF_all_com.php";
include_once "CFclass/CF_support.php";

// Create project drop down

if(isset($_REQUEST['project_id'])){
    $project_id = $_REQUEST['project_id'];
    }
else
{
    $project_id = 0;
    }

$prevalue[1]['project_id'] = 0;
$prevalue[1]['project_name'] = 'Select';

$opts['onchangename'] = 'document.switchboard.submit()';
$ar_project_names = get_array_query("SELECT project_id, project_name FROM projects");
$dd_project_names = make_array_select($ar_project_names, 'project_id', 'project_id','project_name',$project_id, 20, $opts, $prevalue);




if($project_id > 0){

	$project_path = lookup_value('project_path','projects'," project_id = $project_id");

    $project_set_text .= "<li class='action_head'>Setup Project </li>\n";
    $project_set_text .= "<li>\n<a href='project_setup.php?project_id=$project_id'>Setup File Structure </a>\n</li>\n";
    $project_set_text .= "<li>\n<a href='project_setup_pdo.php?project_id=$project_id'>Setup File Structure w/PDO </a>\n</li>\n";
    $project_set_text .= "<li>\n<a href='project_inital_setup.php?project_id=$project_id'>Setup Initial Project w/PDO </a>\n</li>\n";
	$project_set_text .= "<li>\n<a href='load_all_tables.php?project_id=$project_id'>Load all DB tables </a>\n</li>\n";	  
	$project_set_text .= "<li>\n<a href='setup_permissions.php?project_id=$project_id'>Add Permission Tables </a>\n</li>\n";	
    
	$project_set_text .= "<li class='action_head'>Individual Set setup </li>\n";
    $project_set_text .= "<li>\n<a target='frame_content' href='variables_list.php?flt_project_id=$project_id'>Add/Edit Variables </a>\n</li>\n";
    $project_set_text .= "<li>\n<a target='frame_content' href='crudsets_list.php?flt_project_id=$project_id'>Add/Edit CRUD sets </a>\n</li>\n";

    $project_set_text .= "<li class='action_head'>Setup scripts (opt) </li>\n";
    $project_set_text .= "<li>\n<a href='get_table_vars.php?project_id=$project_id'>Add Table to Variables </a>\n</li>\n";
    $project_set_text .= "<li>\n<a href='all_table_to_set.php?project_id=$project_id'>Add Table Vars to Set </a>\n</li>\n";
 $project_set_text .= "<li>Select CRUD set \n</li>\n";
    if(isset($_REQUEST['crudset_id'])){
        $crudset_id = $_REQUEST['crudset_id'];
    }
    else
    {
        $crudset_id = 0;
        }
    $precsvalue[1]['crudset_id'] = 0;
    $precsvalue[1]['cs_name'] = 'Select Set';
    $ar_crudset_names = get_array_query("SELECT crudset_id, cs_name FROM crudsets WHERE project_id = $project_id");

    $opts['onchangename'] = 'document.switchboard.submit()';
    $dd_crudset_names = make_array_select($ar_crudset_names, 'crudset_id', 'crudset_id', 'cs_name', $crudset_id, 20, $opts, $precsvalue);
    $project_set_text .= "<li>$dd_crudset_names</li>\n";

    // Make Crudset INFO
    if($crudset_id > 0){

        $crudset_set_text .= "<li>\n<a target='frame_content' href='crudcols_list.php?flt_crudset_id=$crudset_id'>Add/Edit CRUD Cols </a></li>\n";
        $crudset_set_text .= "<li class='action_head'>Output to File</li>\n";
        $crudset_set_text .= "<li>\n<a href='make_fields.php?project_id=$project_id&crudset_id=$crudset_id'>Make Fields </a></li>\n";
        $crudset_set_text .= "<li>\n<a href='make_list_page.php?project_id=$project_id&crudset_id=$crudset_id'>Make List Page </a></li>\n";
        $crudset_set_text .= "<li>\n<a href='make_process_page.php?project_id=$project_id&crudset_id=$crudset_id'>Make Processing Page </a></li>\n";
 		$crudset_set_text .= "<li>\n<a href='make_deditpage.php?project_id=$project_id&crudset_id=$crudset_id'>Make dynamic Edit Form </a></li>\n";
		$crudset_set_text .= "<li>\n<a href='make_editpage.php?project_id=$project_id&crudset_id=$crudset_id'>Make Edit Form </a></li>\n";
		$crudset_set_text .= "<li>\n<a href='make_static_form.php?project_id=$project_id&crudset_id=$crudset_id'>Make Static Edit Form </a></li>\n";

		$crudset_set_text .= "<li>\n<a href='make_basic_list.php?project_id=$project_id&crudset_id=$crudset_id'>Make Basic Table </a></li>\n";
		$crudset_set_text .= "<li>\n<a href='make_mform_page.php?project_id=$project_id&crudset_id=$crudset_id'>Make multi-Form</a></li>\n";
		$crudset_set_text .= "<li>\n<a target='frame_content' href='make_treepick_page.php?project_id=$project_id&crudset_id=$crudset_id'>Make Tree-Picker</a></li>\n";      
		
		
        $crudset_set_text .= "<li class='action_head'>Output to Screen</li>\n";
        $crudset_set_text .= "<li>\n<a target='frame_content' href='make_fields.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Make Fields </a></li>\n";
        $crudset_set_text .= "<li>\n<a target='frame_content' href='make_list_page.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Make List Page </a></li>\n";
        $crudset_set_text .= "<li>\n<a target='frame_content' href='make_process_page.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Make Processing Page </a></li>\n";
        $crudset_set_text .= "<li>\n<a target='frame_content' href='make_editpage.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Make Edit Form </a></li>\n";
        $crudset_set_text .= "<li>\n<a target='frame_content' href='make_basic_list.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Make Basic Table </a></li>\n";
		$crudset_set_text .= "<li>\n<a target='frame_content' href='make_mform_page.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" ."'>Make multi-Form</a></li>\n"; 
 		$crudset_set_text .= "<li>\n<a target='frame_content' href='make_treepick_page.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" ."'>Make Tree-Pick</a></li>\n"; 
 
 $crudset_set_text .= "<li class='action_head'>CRUDset Operations</li>\n";
        $crudset_set_text .= "<li>\n<a target='frame_content' href='copy_crudset.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Copy Set</a></li>\n";
		$crudset_set_text .= "<li>\n<a target='frame_content' href='delete_crudset.php?project_id=$project_id&crudset_id=$crudset_id" . "&output=screen" . "'>Delete Set</a></li>\n";
 }

	$after_set_text .= "<li class='action_head'>File Operations</li>\n";
    $after_set_text .= "<li>\n<a target='_blank'	href='projects/$project_path/'>Open Project Directory</a>\n</li>\n";
    $after_set_text .= "<li>\n<a target='frame_content'	href='make_left_menu.php?project_id=$project_id'>Make Basic Left Menu</a>\n</li>\n";
     
    }
?>
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
    <title>QucikCrud Menu</title>
<link rel="stylesheet" href="mainstyle.css" type="text/css">
</head>

<body>



	<div id="act_menu">
    <form name="switchboard" action="leftmenu.php">	
	<ul class="rm_list">
			<li class='title_head' >QuickCRUD</li>
			<li class='title_head' >Interface Tool </li>
			<li><a target='frame_content' href='homepage.php'>Home </li>
			<li><a target='frame_content' href='homepage.php'>Instructions </li>
			<li><a target='_blank' href='projects/'>Project Directories </li>			
            <li class='action_head' >Select Project</li>
			<li><a target='frame_content' href='projects_list.php'>Add/Edit Projects</a></li>		
            <li><?php print $dd_project_names ?></li>

            
            <?php print $project_set_text;
            print $crudset_set_text;
            print $crudcol_set_text;
			print $after_set_text;
            ?>
     </ul>
	 </form>
	 </div> <!-- end act_menu -->

    </table>
    </form>


</body>


</html>